# cppgl.py
"""
CPPGL (每克肝脏的细胞质蛋白含量) 和 S9PPGL (每克肝脏的S9蛋白含量) 计算模块
"""
from .variation_utils import apply_variation

def calculate_base_cppgl(mppgl, cppgl_baseline, cppgl_slope):
    """
    计算基础CPPGL值(无变异)
    
    公式: CPPGL = baseline + slope * MPPGL
    
    参数:
    mppgl: 每克肝脏的微粒体蛋白含量 (mg/g)
    cppgl_baseline: CPPGL基准值(截距)
    cppgl_slope: MPPGL系数(斜率)
    
    返回:
    基础CPPGL值 (mg/g)
    """
    # 使用公式计算CPPGL
    cppgl = cppgl_baseline + cppgl_slope * mppgl
    
    return cppgl

def calculate_cppgl(mppgl, cppgl_baseline, cppgl_slope, cppgl_cv):
    """
    计算每克肝脏的细胞质蛋白含量(CPPGL)，包含变异
    
    参数:
    mppgl: 每克肝脏的微粒体蛋白含量 (mg/g)
    cppgl_baseline: CPPGL基准值(截距)
    cppgl_slope: MPPGL系数(斜率)
    cppgl_cv: CPPGL变异系数(%)
    
    返回:
    CPPGL值 (mg/g)
    """
    # 获取基础CPPGL值
    base_cppgl = calculate_base_cppgl(mppgl, cppgl_baseline, cppgl_slope)
    
    # 应用变异
    return apply_variation(base_cppgl, cppgl_cv)

def calculate_s9ppgl(mppgl, cppgl):
    """
    计算每克肝脏的S9蛋白含量(S9PPGL)
    
    公式: S9PPGL = MPPGL + CPPGL
    
    参数:
    mppgl: 每克肝脏的微粒体蛋白含量 (mg/g)
    cppgl: 每克肝脏的细胞质蛋白含量 (mg/g)
    
    返回:
    S9PPGL值 (mg/g)
    """
    # S9PPGL = MPPGL + CPPGL
    return mppgl + cppgl
